<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"  src="../../jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#searchId').click(function(){
		var form = document.searchForm;
		//이름 check
		if (!form.id.value){
			alert("아이디를 입력하세요");
			form.name.focus();
			return false;
		}
		if(isNaN(form.registerNumber1.value)||isNaN(form.registerNumber2.value)){
			alert("주민번호는 숫자로 입력해주세요");
			return false;
		}else	if(form.registerNumber1.value.length!=6 ||form.registerNumber2.value.length!=7 ){
			alert("주민번호를 올바르게 입력하세요");
			return false;
		}
		var queryString = "id="+$('#id').val()+"&registerNumber1="+$('#registerNumber1').val()+"&registerNumber2="+$('#registerNumber2').val(); 
		$.ajax({
			url : "/${initParam.context_root}/searchPassword.do",
			type : "post",
			data : queryString,
			success : function(result){
				alert(result);
				if(result.trim() == "null"){
					alert("잘못된 정보입니다");
				}else{
					$("#layer").html("회원님의 비밀번호는 " + result + " 입니다");
				}
			}
		});
	});
});
function resetTxt(txt){
	txt.value="";
}
</script>
<title>Insert title here</title>
</head>
<body>
<form name="searchForm"action="">

<table>
	<tr>
		<td>아이디 : </td> 
		 <td> <input type="text" name="id" id="id"  size="20" maxlength="10" onfocus="resetTxt(this)" size="10"></td>
	</tr>
	<tr>
		<td>주민등록번호 : </td>
		<td> <input type="text" name="registerNumber1" id="registerNumber1" maxlength="6" onfocus="resetTxt(this)" size="6"> - 
				  <input type="password" name="registerNumber2" id="registerNumber2"maxlength="7" size="7">
				  <input type="button" id="searchId" name="searchPassword" value="비밀번호찾기"/>
		</td>
	</tr>
</table>
</form>

<fieldset> <!-- style="width:50%" -->
<legend>조회결과</legend>  <!-- 라벨 이름 -->
<div id="layer"></div> <!-- 조회된 결과값-->
</fieldset>
</body>
</html>